package com.qdrtme.landemo.root;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.EditText;

import com.orhanobut.logger.Logger;
import com.qdrtme.landemo.BaseApi;
import com.qdrtme.landemo.R;
import com.qdrtme.landemo.api.SmsResetPasswordApi;
import com.qdrtme.landemo.webapi.WebAPIListener;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * @Created by taylor on 12/11/17.
 * @class 短信重置密码
 */

public class SmsResetPasswordActivity extends AppCompatActivity {

    @BindView(R.id.et_reset_phone)
    EditText phoneEt;
    @BindView(R.id.et_reset_password)
    EditText passwordEt;
    @BindView(R.id.et_code)
    EditText codeEt;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sms_reset_password);
        ButterKnife.bind(this);

    }

    @OnClick({R.id.btn_reset_comfirm})
    public void onClickTT(View v) {
        switch (v.getId()) {
            case R.id.btn_reset_comfirm:
                smsResetPassword();
                break;
        }
    }

    private void smsResetPassword() {
        SmsResetPasswordApi smsResetPasswordApi = new SmsResetPasswordApi(this);
        smsResetPasswordApi.setTenantid(BaseApi.LJ_TENANT_ID);
        smsResetPasswordApi.setMobile(phoneEt.getText().toString().trim());
        smsResetPasswordApi.setVerify(codeEt.getText().toString().trim());
        smsResetPasswordApi.setRepassword(passwordEt.getText().toString().trim());
        smsResetPasswordApi.setNewpassword(passwordEt.getText().toString().trim());
        smsResetPasswordApi.doHttpPost(new WebAPIListener() {
            @Override
            public void onStart() {

            }

            @Override
            public void onFinish() {

            }

            @Override
            public void onSuccess(String result) {
                Logger.json(result);
            }

            @Override
            public void onFail(int errCode, String errMessage) {

            }
        });
    }
}
